package com.zhss.eshop.auth.service.Impl;

import com.github.pagehelper.PageHelper;
import com.zhss.eshop.auth.domain.model.AuthRole;
import com.zhss.eshop.auth.mapper.AuthRoleMapper;
import com.zhss.eshop.auth.service.AuthRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AuthRoleServiceImpl implements AuthRoleService{

    @Resource
    private AuthRoleMapper authRoleMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return authRoleMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(AuthRole record) {
        //新增角色和权限的关联关系未做
        return authRoleMapper.insertSelective(record);
    }

    @Override
    public AuthRole selectByPrimaryKey(Long id) {
        return authRoleMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(AuthRole record) {
        return authRoleMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public List<AuthRole> listByPage(Integer page, Integer limit, String code, String name) throws Exception {
        PageHelper.startPage(page, limit);
        List<AuthRole> authRoles = authRoleMapper.listByPage(name, code);
        return authRoles;
    }

}
